package com.icss.domian;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;

/**
 * @MantToMany:代表的是teacher对student是多对多的关系
 *     targetEntity:目标实体类，对应关系的实体类
 * @JoinColumn:连接字段，外键。外键设置在两个表中，
 *     name:外键的字段名字,来源于主表的主键
 *     referencedColumnName:外键的引用，属性
 */
/**
 * @OneToMany:代表的是Role对User是一对多的关系
 *     targetEntity:目标实体类，对应关系的实体类
 * @JoinColumn:连接字段，外键。外键设置在多的一方的表，user表中
 *     name:外键的字段名字,来源于主表的主键
 *     referencedColumnName:外键的引用，属性
 */

@Entity
@Table(name = "t_vehicle_illegal_record")
public class VehicleIllegalRecord implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "illegal_record_id")
    private Integer illegalRecordId;
    @Column(name="illegal_record_time")
    private Date illegalRecordTime;
    @Column(name = "illegal_record_license")
    private String illegalRecordLicense;//车牌号
    @Column(name = "illegal_record_address")
    private String illegalRecordAddress;//地点
    @Column(name = "illegal_record_status")
    private Integer illegalRecordStatus;//0代表未处理，1代表已处理

    //一条违法记录只属于一个用户
    @ManyToOne(targetEntity = User.class)
    @JoinColumn(name = "user_id" ,referencedColumnName = "user_id")
    private User user;

    //一条违法记录，包含一个违法行为
    @ManyToOne(targetEntity = IllegalItem.class)
    @JoinColumn(name = "illegal_item_id", referencedColumnName = "illegal_item_id")
    private IllegalItem illegalItem;


    public Integer getIllegalRecordId() {
        return illegalRecordId;
    }

    public void setIllegalRecordId(Integer illegalRecordId) {
        this.illegalRecordId = illegalRecordId;
    }

    public Date getIllegalRecordTime() {
        return illegalRecordTime;
    }

    public void setIllegalRecordTime(Date illegalRecordTime) {
        this.illegalRecordTime = illegalRecordTime;
    }


//    public Timestamp getIllegalRecordTime() {
//        return illegalRecordTime;
//    }
//
//    public void setIllegalRecordTime(Timestamp illegalRecordTime) {
//        this.illegalRecordTime = illegalRecordTime;
//    }

    public String getIllegalRecordLicense() {
        return illegalRecordLicense;
    }

    public void setIllegalRecordLicense(String illegalRecordLicense) {
        this.illegalRecordLicense = illegalRecordLicense;
    }

    public String getIllegalRecordAddress() {
        return illegalRecordAddress;
    }

    public void setIllegalRecordAddress(String illegalRecordAddress) {
        this.illegalRecordAddress = illegalRecordAddress;
    }

    public Integer getIllegalRecordStatus() {
        return illegalRecordStatus;
    }

    public void setIllegalRecordStatus(Integer illegalRecordStatus) {
        this.illegalRecordStatus = illegalRecordStatus;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public IllegalItem getIllegalItem() {
        return illegalItem;
    }

    public void setIllegalItem(IllegalItem illegalItem) {
        this.illegalItem = illegalItem;
    }
    @Override
    public String toString() {
        return "VehicleIllegalRecord{" +
                "illegalRecordId=" + illegalRecordId +
                ", illegalRecordTime=" + illegalRecordTime +
                ", illegalRecordLicense='" + illegalRecordLicense + '\'' +
                ", illegalRecordAddress='" + illegalRecordAddress + '\'' +
                ", illegalRecordStatus=" + illegalRecordStatus +
                '}';
    }
}
